{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Starting Five\n", "## Problem Definition\n", "You are the trainer of a basketball team playing an inter-university tournament over a weekend. You won the first game of the tournament yesterday, and now you have to decide whether to play with the same starting 5 or make changes in the team. You want to assess your decision considering the possibilities of winning ($p_w$) or loosing($p_l$) the game and of having any player injured ($p_i$) or all healthy ($p_h$) after the game. Since it is a friendly tournament, your priority is that none of your classmates ends up injured, so you establish the following priorities between the utility values of the possible outcomes: v1 (victory – no injuries) > v2 (loose – no injuries) > v3 (win – any injured) > v4 (loose – any injured)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**a.** Draw a decision tree indicating the probabilities and utility values of the possible outcomes, considering that the probability of winning or loosing and the probability of having any player injured or all healthy are independent and also independent of your decision to make changes in the team.\n", "\n", "The following decision tree represents the solution of the problem:\n", "\n", "![starting_five_solution](img/starting_five_1.PNG){width=50%}\n", "\n", "\n", "Run the code if you want to generate it yourself using Python!" ] }, { "cell_type": "code", "metadata": {}, "source": [ "from graphviz import Digraph\n", "# Create Digraph object\n", "din = Digraph(format='png')\n", "din.graph_attr['rankdir'] = 'LR'\n", "\n", "# Add root node\n", "din.node('1', shape='square', style=\"filled\", fillcolor='yellow')\n", "\n", "# First branch nodes\n", "din.node('2', shape='circle', style=\"filled\", fillcolor='green')\n", "\n", "din.node('3', shape='circle', style='filled', fillcolor='green')\n", "\n", "din.node('4', xlabel='V1', shape='diamond', style='filled', fillcolor='purple')\n", "din.node('5', xlabel='V2', shape='diamond', style='filled', fillcolor='purple')\n", "\n", "din.node('6', shape='circle', style='filled', fillcolor='green')\n", "\n", "din.node('7', xlabel='V3', shape='diamond', style='filled', fillcolor='purple')\n", "din.node('8', xlabel='V4', shape='diamond', style='filled', fillcolor='purple')\n", "\n", "# Second branch\n", "din.node('9', shape='circle', style=\"filled\", fillcolor='green')\n", "\n", "din.node('10', shape='circle', style='filled', fillcolor='green')\n", "\n", "din.node('11', xlabel='V1', shape='diamond', style='filled', fillcolor='purple')\n", "din.node('12', xlabel='V2', shape='diamond', style='filled', fillcolor='purple')\n", "\n", "din.node('13', shape='circle', style='filled', fillcolor='green')\n", "\n", "din.node('14', xlabel='V3', shape='diamond', style='filled', fillcolor='purple')\n", "din.node('15', xlabel='V4', shape='diamond', style='filled', fillcolor='purple')\n", "\n", "din.edge('1', '2', 'Same starting five')\n", "din.edge('1', '9', 'Make changes')\n", "\n", "din.edge('2', '3', 'Win (pw)')\n", "din.edge('2', '6', 'Loose (pl)')\n", "\n", "din.edge('3', '4', 'No injuries (ph)')\n", "din.edge('3', '5', 'Any injured (pi)')\n", "\n", "din.edge('6', '7', 'No injuries (ph)')\n", "din.edge('6', '8', 'Any injured (pi)')\n", "\n", "din.edge('9', '10', 'Win (pw)')\n", "din.edge('9', '13', 'Loose (pl)')\n", "\n", "din.edge('10', '11', 'No injuries (ph)')\n", "din.edge('10', '12', 'Any injured (pi)')\n", "\n", "din.edge('13', '14', 'No injuries (ph)')\n", "din.edge('13', '15', 'Any injured (pi)')\n", "\n", "din" ], "outputs": [], "execution_count": null }, { "cell_type": "markdown", "metadata": {}, "source": [ "**b.**\tHow would the decision tree change if you consider that the probability of having any player injured is not independent of your decision to make changes?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We need to take into account the conditional probabilities of:\n", "- p(i|s): Probability of having an injury given that we play with the same (s) team.\n", "- p(h|s): Probability of not having any injury given that we play with the same team\n", "- p(i|c): Probability of having an injury given that we make changes (c)\n", "- p(h|c): Probability of not having any injury given that we play with a different starting team\n", "\n", "With this posterior probabilities, we can redraw the decision tree as follows: \n", "\n", "![starting_five_2](img/starting_five_2.PNG){width=50%}\n", "\n", "This image was generated with the following Python script:" ] }, { "cell_type": "code", "metadata": {}, "source": [ "from graphviz import Digraph\n", "# Create Digraph object\n", "din = Digraph(format='png')\n", "din.graph_attr['rankdir'] = 'LR'\n", "\n", "# Add root node\n", "din.node('1', shape='square', style=\"filled\", fillcolor='yellow')\n", "\n", "# First branch nodes\n", "din.node('2', shape='circle', style=\"filled\", fillcolor='green')\n", "\n", "din.node('3', shape='circle', style='filled', fillcolor='green')\n", "\n", "din.node('4', xlabel='V1', shape='diamond', style='filled', fillcolor='purple')\n", "din.node('5', xlabel='V2', shape='diamond', style='filled', fillcolor='purple')\n", "\n", "din.node('6', shape='circle', style='filled', fillcolor='green')\n", "\n", "din.node('7', xlabel='V3', shape='diamond', style='filled', fillcolor='purple')\n", "din.node('8', xlabel='V4', shape='diamond', style='filled', fillcolor='purple')\n", "\n", "# Second branch\n", "din.node('9', shape='circle', style=\"filled\", fillcolor='green')\n", "\n", "din.node('10', shape='circle', style='filled', fillcolor='green')\n", "\n", "din.node('11', xlabel='V1', shape='diamond', style='filled', fillcolor='purple')\n", "din.node('12', xlabel='V2', shape='diamond', style='filled', fillcolor='purple')\n", "\n", "din.node('13', shape='circle', style='filled', fillcolor='green')\n", "\n", "din.node('14', xlabel='V3', shape='diamond', style='filled', fillcolor='purple')\n", "din.node('15', xlabel='V4', shape='diamond', style='filled', fillcolor='purple')\n", "\n", "din.edge('1', '2', 'Same starting five')\n", "din.edge('1', '9', 'Make changes')\n", "\n", "din.edge('2', '3', 'Win (pw)')\n", "din.edge('2', '6', 'Loose (pl)')\n", "\n", "din.edge('3', '4', 'No injuries (p(h|s))')\n", "din.edge('3', '5', 'Any injured (p(i|s))')\n", "\n", "din.edge('6', '7', 'No injuries (p(h|s))')\n", "din.edge('6', '8', 'Any injured (p(i|s))')\n", "\n", "din.edge('9', '10', 'Win (pw)')\n", "din.edge('9', '13', 'Loose (pl)')\n", "\n", "din.edge('10', '11', 'No injuries (p(h|c))')\n", "din.edge('10', '12', 'Any injured (p(i|c))')\n", "\n", "din.edge('13', '14', 'No injuries (p(h|c))')\n", "din.edge('13', '15', 'Any injured (p(i|c))')\n", "\n", "din" ], "outputs": [], "execution_count": null } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.4" }, "pycharm": { "stem_cell": { "cell_type": "raw", "source": [], "metadata": { "collapsed": false } } } }, "nbformat": 4, "nbformat_minor": 2 }